package lingou.homework.postbar.service.enums;

import lingou.homework.postbar.domain.Post;
import lingou.homework.postbar.domain.User;
import lingou.homework.postbar.exception.BusinessException;
import lingou.homework.postbar.service.PostService;
import lingou.homework.postbar.service.tool.Tools;

public enum MessageOpEnum {
    LIKE(0){
//        @Override
//        public String genMessage(User opUser, Post post, PostService postService) {
//            return "%s 点赞了你的帖子 %s".formatted(Tools.genAt(opUser), Tools.genPostLink(post));
//        }
    },
    REPLY(1) {
//        @Override
//        public String genMessage(User opUser, Post post, PostService postService) {
//            return "%s 回复了你的帖子 %s: <p>%s</p>".formatted(
//                    Tools.genAt(opUser),
//                    Tools.genPostLink(postService.getFatherPost(post.getPostId())),
//                    Tools.genPostLink(post));
//        }
    },
    ASK(2) {
//        @Override
//        public String genMessage(User opUser, Post post, PostService postService) {
//            return "%s 向你提问: %s".formatted(
//                    Tools.genAt(opUser),
//                    Tools.genPostLink(post)
//            );
//        }
    },
    NOTICE(3),
    DELETE(4);
    private long id;
    MessageOpEnum(long id) {
        this.id = id;
    }
    public long getId(){
        return this.id;
    }
    public static MessageOpEnum select(long id){
        for (MessageOpEnum value : values()) {
            if(value.id == id) return value;
        }
        throw new BusinessException("未知的通知类型！");
    }
//    public abstract String genMessage(User opUser, Post post, PostService postService);
}
